import {queryLog} from '../services/api';

export default {
  namespace: "log",
  state: {
    data: {
      list: [],
      pagination: {},
    },
  },
  effects: {
    * fetch({payload}, {call, put}) {
      const response = yield call(queryLog, payload);
      yield put({
        type: 'save',
        payload: response,
      });
    },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        data: {
          list: action.payload.records,
          pagination: {
            total: action.payload.total,
            pageSize: action.payload.size,
            current: action.payload.current,
          },
        },
      };
    },
  },
};

